package com.yunbao.demo.controller;

import com.yunbao.demo.permission.Security;
import com.yunbao.demo.service.DemoService;
import com.yunbao.ioc.annotation.Autowired;
import com.yunbao.ioc.annotation.Controller;
import com.yunbao.ioc.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by louisyuu on 2020/3/14 下午1:42
 */

@Controller
@RequestMapping("/demo")
public class DemoController {


    public final static String ADMIN = "admin";

    public final static String MANAGER = "manager";


    public final static String COMMON = "common";


    @Autowired
    private DemoService demoService;


    @RequestMapping("/show")
    public String show(HttpServletRequest request, HttpServletResponse response, String username) {

        System.out.println("===========================");
        System.out.println("HttpServletRequest " + request);

        System.out.println("HttpServletResponse " + response);
        System.out.println("name " + username);
        return demoService.show(username);
    }



    @RequestMapping("/setting")
    @Security(values = {ADMIN,MANAGER})
    public String setting(HttpServletRequest request, HttpServletResponse response, String username) {


        return "do setting....by "+username;
    }




    @RequestMapping("/createUser")
    @Security(values = {ADMIN,MANAGER})
    public String createUser(HttpServletRequest request, HttpServletResponse response, String username) {


        return "do create user....by "+username;
    }








}
